[#ftl]
[@define "agile._WorkspaceContext"]
	widgetsToPaste:null
	,constructor:function(){
		this.widgetsToPaste = [];
		aspect.after(this,"startup",lang.hitch(this,"createContextMenu"));
		
		this.subscribe("agile.widget.selectedTarget",function(selectedTarget,offset){
//			//console.log("agile.widget.selectedTarget**",selectedTarget.declaredClass,offset);
			if(!this.selected) {
				this.selectedTarget = null;
				this.targetOffset = null;
				return;
			}
			
			this.selectedTarget = selectedTarget;
			this.targetOffset = offset;
		});	
		
		//commands from Toolbar or MenuBar
		[@keyword "actionOnCommand"/]
		this.subscribe("agile.command",function(command,event){
//			console.log("@WorkspaceContext:selected=",this.selected,this.title);
			if(!this.selected) return;
			try{
				if(this["actionOnCommand" + command]){
					this["actionOnCommand" + command]();
//					console.log("function 'actionOnCommand" + command +"' is triggered");
				}else{
//					console.error("function 'actionOnCommand" + command +"' is not defined");
					topic.publish("agile.message","info",null,command + " function is not implemented yet",null);
				}	
			}catch(e){
				topic.publish("agile.message","error",null,"Error occurred while try to " + command,e);
			}
		});
	}
	[@method "createContextMenu"/]
	,createContextMenu:function(){
		var pMenu = new dijit.Menu({
	        targetNodeIds: [this.containerNode]
	    });
		var contextContainerNode = this.containerNode;
		var workContext = this;
		
		pMenu.addChild(new dijit.MenuItem({
            label: agile.i18n("Copy",null,true)
            ,iconClass: "dijitEditorIcon dijitEditorIconCopy"
            ,accelKey:"Ctrl + C" 
            ,onClick: function(event) {
            	topic.publish("agile.command","Copy");
            }
			,resetState:function(){
				//console.log("agileSelected=",query(".agileSelected",contextContainerNode));
				this.set("disabled",query(".agileSelected",contextContainerNode).length == 0);								
			}
        }));
		
        pMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Delete",null,true)
            ,iconClass: "dijitEditorIcon dijitEditorIconDelete"
            ,accelKey:"DELETE"	
            ,onClick: function(event) {
            	topic.publish("agile.command","Delete");
            }
	        ,resetState:function(){
				this.set("disabled",query(".agileSelected",contextContainerNode).length == 0);
			}
        }));
        pMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Cut",null,true)
            ,iconClass: "dijitEditorIcon dijitEditorIconCut"
            ,accelKey:"Ctrl + X"	
            ,onClick: function(event) {            
            	topic.publish("agile.command","Cut");
            }
	        ,resetState:function(){
				this.set("disabled",query(".agileSelected",contextContainerNode).length == 0);
			}
        }));
        
        pMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Paste",null,true)
            ,iconClass: "dijitEditorIcon dijitEditorIconPaste"
            ,accelKey:"Ctrl + V"	
            ,onClick: function(event) {
            	topic.publish("agile.command","Paste");
            }	        
	        ,resetState:function(){
	        	this.set("disabled",workContext.widgetsToPaste.length == 0);				
			}
        }));

        pMenu.addChild(new dijit.MenuSeparator());

        //fixme:TODO 20150522:pin widget & allow selection in widget
        pMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Pin",null,true)
            ,onClick: function(event) {
            	//event.stopPropagation();
            	//_event.stop(event);
            	topic.publish("agile.command","Pin");
            }	        
	        ,resetState:function(){
	        	//this.set("disabled",query(".agileSelected",contextContainerNode).length == 0);	        	
	        	//this.set("disabled",!workContext.selectedTarget.metadata("moveable"));	        	
	        	this.set("disabled",!workContext.selectedTarget.adviseContextState("Pin"));	        	
			}
        }));
        pMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Unpin",null,true)
            ,onClick: function(event) {
            	//event.stopPropagation();
            	//_event.stop(event);
            	topic.publish("agile.command","Unpin");
            }	        
	        ,resetState:function(){
	        	//this.set("disabled",query(".agileSelected",contextContainerNode).length == 0);
	        	//this.set("disabled",workContext.selectedTarget.metadata("moveable"));
	        	this.set("disabled",!workContext.selectedTarget.adviseContextState("Unpin"));
			}
        }));
        
        var pSubMenu = new dijit.Menu();
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Left",null,true)
            //,iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft"
        	,onClick: function(event) {
        		topic.publish("agile.command","JustifyLeft");
            }
	        ,resetState:function(){			
			}
        }));
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Right",null,true)
        	//,iconClass: "dijitEditorIcon dijitEditorIconJustifyRight"
        	,onClick: function(event) {            	
        		topic.publish("agile.command","JustifyRight");
            }
	        ,resetState:function(){
			}            	
        }));
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Top",null,true)
        	,onClick: function(event) {
            	//target.alignSelectedComponents(event,"top");
        		topic.publish("agile.command","JustifyTop");
            }
	        ,resetState:function(){				
			}
        }));
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Bottom",null,true)
        	,onClick: function(event) {
            	//target.alignSelectedComponents(event,"bottom");
        		topic.publish("agile.command","JustifyBottom");
            }
	        ,resetState:function(){				
			}
        }));
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Width",null,true)
        	,onClick: function(event) {
            	//target.alignSelectedComponents(event,"width");
        		topic.publish("agile.command","JustifyWidth");
            }
	        ,resetState:function(){				
			}
        }));
        
        pSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Justify_Height",null,true)
        	,onClick: function(event) {
            	//target.alignSelectedComponents(event,"height");
        		topic.publish("agile.command","JustifyHeight");
            }
	        ,resetState:function(){				
			}
        }));
        
        pMenu.addChild(new dijit.PopupMenuItem({
            label:agile.i18n("Justify",null,true)
            ,popup: pSubMenu            
	        ,resetState:function(){
				//this.set("disabled",query(".agileSelected",contextContainerNode).length <= 1);
				
	        	var selected = false;
				var nodes = query(".agileSelected",contextContainerNode);
				if(workContext.selectedTarget){
					for(var i = 0; i < nodes.length; i++){
						if(nodes[i] == workContext.selectedTarget.domNode){
							selected = true;
							break;
						}
					}
				}
				this.set("disabled",!selected || nodes.length <= 1);
			}
        }));

        var layerSubMenu = new dijit.Menu();
        layerSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Move_to_back",null,true)
        	,onClick: function(event) {
//        		workContext.selectedTarget.moveLayer("back");
				query(".agileSelected",contextContainerNode).forEach(function(node){
					registry.byNode(node).moveLayer("back");
				},this);
            }
	        ,title:"Move current componet to the bottom layer"
	        //,accelKey:"Ctrl + PageDown"
        }));
        layerSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Move_to_front",null,true)
        	,onClick: function(event) {
//        		workContext.selectedTarget.moveLayer("front");
        		query(".agileSelected",contextContainerNode).forEach(function(node){
					registry.byNode(node).moveLayer("front");
				},this);
            }
        	,title:"Move current componet to the most upfront layer"
        	//,accelKey:"Ctrl + PageUp"
        }));
        layerSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Move_backwards",null,true)
        	,onClick: function(event) {
//        		workContext.selectedTarget.moveLayer("backwards");
        		query(".agileSelected",contextContainerNode).forEach(function(node){
					registry.byNode(node).moveLayer("backwards");
				},this);
            }
        	,title:"Move current componet one layer backwards"
        	//,accelKey:"Ctrl + Down"
        }));
        layerSubMenu.addChild(new dijit.MenuItem({
            label:agile.i18n("Move_forwards",null,true)
        	,onClick: function(event) {      		
//        		workContext.selectedTarget.moveLayer("forwards");
        		query(".agileSelected",contextContainerNode).forEach(function(node){
					registry.byNode(node).moveLayer("forwards");
				},this);
            }
        	,title:"Move current componet one layer forwards"
        	//,accelKey:"Ctrl + Up"
        }));
        pMenu.addChild(new dijit.PopupMenuItem({
            label:agile.i18n("Layer",null,true)
            ,popup: layerSubMenu
	        ,resetState:function(){
				this.set("disabled",query(".agileSelected",contextContainerNode).length != 1);								
			}
        	,title:"Move current componet among layers"
        }));
        pMenu.addChild(new dijit.MenuSeparator());
        
	    pMenu.addChild(new dijit.MenuItem({
	        label: agile.i18n("Preview",null,true)           	
	        ,onClick: function(event) {            	
	        	topic.publish("agile.workspace.command","Preview");
	        }	    
		    ,resetState:function(){						
	    		if(workContext.selectedTarget.adviseContextState("Preview")){
	    			style.set(this.domNode,{display:""});	
	    		}else{
	    			style.set(this.domNode,{display:"none"});
	    		}
	    	}
		    ,style:"display:none"
	    }));
	    
	    pMenu.addChild(new dijit.MenuItem({
	        label:agile.i18n("Refresh",null,true)           	
	        ,onClick: function(event) {            	
	        	topic.publish("agile.workspace.command","Refresh");
	        }
	    	//,disabled:[#if hasServerResource]false[#else]true[/#if]
	        ,resetState:function(){						
	    		if(workContext.selectedTarget.adviseContextState("Refresh")){
	    			style.set(this.domNode,{display:""});	
	    		}else{
	    			style.set(this.domNode,{display:"none"});
	    		}
	    	}
	        ,style:"display:none"
	    }));
	    
	    
//	    var templateResetState = function(){
//    		var nodes = query(".agileSelected",contextContainerNode);	    						
//    		if(nodes.length == 1 && workContext.selectedTarget && nodes[0] == workContext.selectedTarget.domNode && workContext.selectedTarget.adviseContextState("Save_template")){
//    			style.set(this.domNode,{display:""});	
//    		}else{
//    			style.set(this.domNode,{display:"none"});
//    		}
//    	};

    	pMenu.addChild(new dijit.MenuItem({
   		 	label: agile.i18n("Edit_template",null,true)           	
	        ,onClick: function(event) {
	        	topic.publish("agile.command.Template","editTemplate",workContext.selectedTarget);
	        }	
	    	,resetState:function(){						
	    		if(workContext.selectedTarget && workContext.selectedTarget.adviseContextState("EditTemplate")){
	    			style.set(this.domNode,{display:""});	
	    		}else{
	    			style.set(this.domNode,{display:"none"});
	    		}
	    	}
	    	,style:"display:none"
    	}));
    	
    	pMenu.addChild(new dijit.MenuItem({
    		 label: agile.i18n("Save_template",null,true)           	
 	        ,onClick: function(event) {
 	        	topic.publish("agile.command.Template","saveTemplate",workContext.selectedTarget);
 	        }
	    	,resetState:function(){						
	    		if(workContext.selectedTarget && workContext.selectedTarget.adviseContextState("SaveTemplate")){
	    			style.set(this.domNode,{display:""});	
	    		}else{
	    			style.set(this.domNode,{display:"none"});
	    		}
	    	}
	    	,style:"display:none"
        }));
    	
//    	tplSubMenu.addChild(new dijit.MenuItem({
//    		label: agile.i18n("Save_as_new_template",null,true)           	
//	        ,onClick: function(event) {
//	        	topic.publish("agile.command.Template","save",workContext.selectedTarget,"tpl" + (new Date().getTime()));
//	        }	
//       }));
    	
//    	tplSubMenu.addChild(new dijit.MenuItem({
//    		label: agile.i18n("Refresh",null,true)           	
//	        ,onClick: function(event) {
//	        	topic.publish("agile.command.Template","refresh",workContext.selectedTarget);
//	        }	
//       }));
    	
//	    pMenu.addChild(new dijit.PopupMenuItem({
//            label:agile.i18n("Template",null,true)
//            ,popup: tplSubMenu            
//	        ,resetState:function(){
//	    		var nodes = query(".agileSelected",contextContainerNode);	    						
//	    		if(nodes.length == 1 && workContext.selectedTarget && nodes[0] == workContext.selectedTarget.domNode && workContext.selectedTarget.adviseContextState("Template")){
//	    			style.set(this.domNode,{display:""});	
//	    		}else{
//	    			style.set(this.domNode,{display:"none"});
//	    		}
//	    	}
//        }));

//	    
//	    pMenu.addChild(new dijit.MenuItem({
//	        label: agile.i18n("Save",null,true)           	
//	        ,onClick: function(event) {
//	        	topic.publish("agile.command.SaveTemplate",[workContext.selectedTarget]);
//	        }	   
//	    	//,resetState:templateResetState
//	    }));
//	    
//	    pMenu.addChild(new dijit.MenuItem({
//	        label: agile.i18n("Copy",null,true)           	
//	        ,onClick: function(event) {
//	        	topic.publish("agile.command.CreateTemplate",[workContext.selectedTarget]);
//	        }	   
//	    	//,resetState:templateResetState
//	    }));
	    
	    pMenu.startup();
	    
	    pMenu.on("open",function(event){
//        	//console.log("@@@@@",event);        	        	
        	array.forEach(pMenu.getChildren(),function(child){
        		if(child.resetState){
        			child.resetState();	
        		}        		        		
        	});
        	//20141022
        	topic.publish("agile.contextmenuopen",event);
        });
	}
	
	,actionOnCommandDelete:function(){
		var widgets = [];
		query(".agileSelected",this.domNode).forEach(function(node){
			var child = registry.getEnclosingWidget(node);			
			if(child && child.isOptional()){
				widgets.push(child);
			}
		});			
		if(widgets.length > 0){
			topic.publish("agile.message.confirm",agile.i18n("msg_remove_confirm"),null,this,{ok:function(){
				var operations = [];
				array.forEach(widgets,function(child){
					child.parent.removeChild(child);
					topic.publish("agile.widget.removed",child);	
					operations.push({action:"delete",target:child});
				});			
				agile.commit(operations);
				topic.publish("agile.widget.selected",this);
			},cancel:function(){}});						
		}	
	}	
	,actionOnCommandCopy:function(){		
		this.widgetsToPaste = [];
		this.isCopy = true;
		query(".agileSelected",this.domNode).forEach(function(node){			
			this.widgetsToPaste.push(registry.getEnclosingWidget(node).clone());
		},this);		
	}
	,actionOnCommandCut:function(){			
		this.widgetsToPaste = [];
		var operations = [];
		query(".agileSelected",this.domNode).forEach(function(node){
			var child = registry.getEnclosingWidget(node);			
			if(child && child.isOptional()){
				this.widgetsToPaste.push(child);
				style.set(child.domNode,{opacity:0.5});		
//				operations.push({action:"update",target:child,category:"style",property:"opacity",beforeValue:"",afterValue:"0.5"});
				operations.push({action:"undo",callback:function(){style.set(child.domNode,{opacity:1.0});}});
			}
		},this);	
		agile.commit(operations);
		this.isCopy = false;
	}
	,actionOnCommandPaste:function(){	
		
		var targetContainer =  this.selectedTarget;
		var targetOffset = this.targetOffset;
//		if(targetContainer == undefined && this.widgetsToPaste.length > 0){
//			var c = this.widgetsToPaste[0];
//			targetContainer = c.parent;
//			targetOffset = {left:c.dimension.left + 10,top:c.dimension.top + 10};
//		}
		if(targetContainer == null || targetOffset == null){
			topic.publish("agile.message.confirm",agile.i18n("msg_tips_paste"));
			return;
		}
		var widgetsToPaste = [];
//		if(this.isCopy){			
			for(var i = 0,size = this.widgetsToPaste.length; i < size; i++){
				widgetsToPaste[i] = this.widgetsToPaste[i].clone();
			}
//		}else{
//			widgetsToPaste = this.widgetsToPaste;
//		}
		if(widgetsToPaste.length == 0){return;}
		var operations = [];				
		var topMostWidget = widgetsToPaste[0];
		for(var i = 1,size = widgetsToPaste.length; i < size; i++){			
			if(topMostWidget.style1("top") > widgetsToPaste[i].style1("top")){
				topMostWidget = widgetsToPaste[i];	
			} 
		}
		var relativePosition = {};
		relativePosition[topMostWidget.id] = targetOffset;
		for(var i = 0,size = widgetsToPaste.length; i < size; i++){
			var widget = widgetsToPaste[i];
			if(topMostWidget != widget){
				relativePosition[widget.id] = {
					left: widget.style1("left") - topMostWidget.style1("left") + targetOffset.left
					,top: widget.style1("top") - topMostWidget.style1("top") + targetOffset.top	
				}
			}			 
		}
		
		for(var i = 0,size = widgetsToPaste.length; i < size; i++){
			var widget = widgetsToPaste[i];			
			targetContainer.addComponent(widget,relativePosition[widget.id]);
			operations.push({action:"add",target:widget});
		}
		//can only paste once for Cut
	    if(!this.isCopy){
	    	var last = agile.commits.shift();
	    	if(last){
	    		operations = operations.concat(last);
	    	}
	    	array.forEach(this.widgetsToPaste,function(child){
	    		child.parent.removeChild(child);	    		
	    		operations.push({action:"delete",target:child});	    		
	    	});	    	
	    	this.widgetsToPaste.splice(0,this.widgetsToPaste.length);
	    }
	    agile.commit(operations);
	}
	,actionOnCommandPin:function(){
		//20150522:pin widget & allow selection in widget
//		query(".agileSelected",this.domNode).forEach(function(node){
//			var widget = registry.getEnclosingWidget(node);
		var widget = this.selectedTarget.getPinTarget();
		//console.log("widget instanceof agile._PinAdvice :",widget instanceof agile._PinAdvice)
			var moveableWidget = widget.moveableWidget;
			if(moveableWidget){
//				widget.metadata("moveableDelay",moveableWidget.delay);
//				moveableWidget.delay = 1000;
				widget.metadata("moveable",false);
				moveableWidget.skip = true;
			}
//		},this);		
	}
	,actionOnCommandUnpin:function(){
		//20150522:pin widget & allow selection in widget
//		query(".agileSelected",this.domNode).forEach(function(node){
//			var widget = registry.getEnclosingWidget(node);
		var widget = this.selectedTarget.getPinTarget(); 
			var moveableWidget = widget.moveableWidget;
			if(moveableWidget){
//				moveableWidget.delay = widget.metadata("moveableDelay");
//				if(moveableWidget.delay == undefined){
//					moveableWidget.delay = 0;
//				}
				widget.metadata("moveable",true);
				moveableWidget.skip = false;
			}
			//topic.publish("agile.widget.selected",null);
//		},this);		
	}
	
	,actionOnCommandJustifyLeft:function(){
		var operations = [];
//		console.log("this.selectedTarget=",this.selectedTarget);
		if(this.selectedTarget && this.selectedTarget.parent){
			var value = this.selectedTarget.style1("left");		
			var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
//			console.log("selectedWidgets=",selectedWidgets);
			for(var i = selectedWidgets.length - 1; i >= 0; i--){
				var beforeValue = selectedWidgets[i].metadata("style.left");
				selectedWidgets[i].style1("left",value);	
				var afterValue = selectedWidgets[i].metadata("style.left");
				operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"left",beforeValue:beforeValue,afterValue:afterValue});
			}
		}else{
			
			var left = [];
			var selectedWidgets = this.getSelectedChildren();
//			console.log("@@selectedWidgets=",selectedWidgets);
			array.forEach(selectedWidgets,function(child){
				left.push(child.dimension.left);
			},this);			
			left.sort();
			
			var leftMost = left[0];
			array.forEach(selectedWidgets,function(child){
				var beforeValue = child.metadata("style.left");
				child.style1("left",leftMost);
				var afterValue = child.metadata("style.left");
				operations.push({action:"update",category:"style",target:child,property:"left",beforeValue:beforeValue,afterValue:afterValue});				
			},this);			
		}
		agile.commit(operations);
	}
	,actionOnCommandJustifyRight:function(){
		var operations = [];
		if(this.selectedTarget && this.selectedTarget.parent){
			var value = this.selectedTarget.style1("left") + this.selectedTarget.style1("width");
			var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
			for(var i = selectedWidgets.length - 1; i >= 0; i--){
				var beforeValue = selectedWidgets[i].metadata("style.left");
				selectedWidgets[i].style1("left",value - selectedWidgets[i].style1("width"));	
				var afterValue = selectedWidgets[i].metadata("style.left");
				operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"left",beforeValue:beforeValue,afterValue:afterValue});				
			}			
		}else{
			var right = [];
			array.forEach(this.getSelectedChildren(),function(child){
				//child.style1("left",rightMost - child.style1("width"));
				right.push(child.dimension.left + child.dimension.width);
			},this);			
			right.sort();
			var rightMost = right[right.length - 1];
			array.forEach(this.getSelectedChildren(),function(child){
				var beforeValue = child.metadata("style.left");
				child.style1("left",rightMost - child.style1("width"));
				var afterValue = child.metadata("style.left");
				operations.push({action:"update",category:"style",target:child,property:"left",beforeValue:beforeValue,afterValue:afterValue});					
			},this);
		}	
		agile.commit(operations);
	}
	,actionOnCommandJustifyTop:function(){
		var operations = [];
		var value = this.selectedTarget.style1("top");
		var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
		for(var i = selectedWidgets.length - 1; i >= 0; i--){				
			var beforeValue = selectedWidgets[i].metadata("style.top");
			selectedWidgets[i].style1("top",value);	
			var afterValue = selectedWidgets[i].metadata("style.top");
			operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"top",beforeValue:beforeValue,afterValue:afterValue});
		}
		agile.commit(operations);
	}
	,actionOnCommandJustifyBottom:function(){		
		var operations = [];
		var value = this.selectedTarget.style1("top") + this.selectedTarget.style1("height");
		var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
		for(var i = selectedWidgets.length - 1; i >= 0; i--){				
			var beforeValue = selectedWidgets[i].metadata("style.top");
			selectedWidgets[i].style1("top",value - selectedWidgets[i].style1("height"));	
			var afterValue = selectedWidgets[i].metadata("style.top");
			operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"top",beforeValue:beforeValue,afterValue:afterValue});
		}
		agile.commit(operations);
	}	
	,actionOnCommandJustifyWidth:function(){	
		var operations = [];
		var value = this.selectedTarget.style1("width");
		var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
		for(var i = selectedWidgets.length - 1; i >= 0; i--){				
			var beforeValue = selectedWidgets[i].metadata("style.width");
			selectedWidgets[i].style1("width",value);
			var afterValue = selectedWidgets[i].metadata("style.width");
			operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"width",beforeValue:beforeValue,afterValue:afterValue});
		}
		agile.commit(operations);
	}	
	,actionOnCommandJustifyHeight:function(){		
		var operations = [];
		var value = this.selectedTarget.style1("height");
		var selectedWidgets = this.selectedTarget.parent.getSelectedChildren();
		for(var i = selectedWidgets.length - 1; i >= 0; i--){
			var beforeValue = selectedWidgets[i].metadata("style.height");
			selectedWidgets[i].style1("height",value);
			var afterValue = selectedWidgets[i].metadata("style.height");
			operations.push({action:"update",category:"style",target:selectedWidgets[i],property:"height",beforeValue:beforeValue,afterValue:afterValue});
		}
		agile.commit(operations);
	}
	,actionOnCommandSave:function(){
		//agile._DataStore		
//		if(!this.store){
//			this.store = (new Date().getTime());	
//		}
		this.save(this.get("store"),this.toHtml({cascade:true,indentCount:0,sourceType:"agile"}));	
	}	
	,actionOnCommandCreateLink:function(){	
		//this.save(this.get("title"),this.toPrototype("agile"));	
	}
	,actionOnCommandUndo:function(){
		agile.undo();
	}
//	,actionOnCommandSaveTemplate:function(){	
//		//this.selectedTarget
//	}	
//	,actionOnCommandFeature:function(){
//		_previewer.set("title",agile.i18n("Help",null,true));
////		agilePrototypeContent.set("href",agile.i18nUrl("feature.html"));
//		_previewer.set("href",agile.i18nUrl("feature.html"));
//		_previewer.show();
//	}
//	,actionOnCommandSupport:function(){
//		_previewer.set("title",agile.i18n("Contact",null,true));		
//		_previewer.set("href",agile.i18nUrl("support.html"));
////		agilePrototypeContent.set("href",agile.i18nUrl("support.html"));
//		_previewer.show();
//	}
[/@]